<template>
  <div>
    <resign-talk :form="resignform" :isinput="true"></resign-talk>
    <el-form ref="form" :model="resignform" label-position="top">
      <el-form-item label="离职分析">
        <el-input type="textarea" v-model="resignform.hrcomment" :disabled="!iscomment"></el-input>
      </el-form-item>

      <el-form-item label="采取措施">
        <el-input type="textarea" v-model="resignform.hrimprove" :disabled="!iscomment"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button v-if="iscomment" style="width: 100%" type="primary" @click="posthrcomment"
          >提交人事意见</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import ResignTalk from "./ResignTalk.vue";
export default {
  components: { ResignTalk },

  created() {
    this.getresigntalkinfo();
  },

  props: ["userid","iscomment"],

  data() {
    return {
      resignform: { reason: [], improve: [] },
    };
  },

  methods: {
    posthrcomment() {
      let datas = {
        id: this.resignform.id,
        hrcomment: this.resignform.hrcomment,
        hrimprove: this.resignform.hrimprove,
      };
      console.log(datas)
      this.$axios
        .post("api/resign/posthrcomment", datas)
        .then((response) => {
          this.$notify({
            title: "HR分析",
            message: "提交成功",
            type: "success",
            duration: 1500,
          });
        })
        .catch(function (error) {
          console.log(error);
        });
    },

    getresigntalkinfo() {
      let datas = {
        userid: this.userid,
      };
      
      this.$axios
        .post("api/resign/getresigntalkinfo", datas)
        .then((response) => {
          this.resignform = response.data;
        })
        .catch(function (error) {
          console.log(error);
        });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>